"use strict";
const common_vendor = require("../common/vendor.js");
const useUserInfoStore = common_vendor.defineStore(
  "userInfo",
  () => {
    const openId = common_vendor.ref(null);
    const token = common_vendor.ref(null);
    const userInfo = common_vendor.ref(null);
    const crowdInfo = common_vendor.ref(null);
    function setOpenId(newVal) {
      openId.value = newVal;
    }
    function setToken(newVal) {
      token.value = newVal;
    }
    function setUserInfo(newVal) {
      userInfo.value = newVal;
    }
    function setCrowdInfo(newVal) {
      crowdInfo.value = newVal;
    }
    function logout() {
      common_vendor.index.removeStorageSync("userInfo");
      userInfo.value = null;
      crowdInfo.value = null;
      openId.value = null;
      token.value = null;
      common_vendor.index.removeStorageSync("privacySatus");
      common_vendor.index.reLaunch({
        url: "/pages/crowd/home/index"
      });
    }
    return {
      userInfo,
      openId,
      token,
      crowdInfo,
      setOpenId,
      setToken,
      setUserInfo,
      setCrowdInfo,
      logout
    };
  },
  {
    persist: true
  }
);
exports.useUserInfoStore = useUserInfoStore;
